<style>

</style>
<template>
    <div>
        <h3>是否通过审核?</h3>
        <Button type="success" @click="auditPass">通过审核</Button>
        <Button type="error" @click="auditFailed">不通过审核</Button>
    </div>
</template>
<script>
import http from '../../../libs/http';
export default {
    data () {
        return {
            aid: ''
        }
    },
    methods: {
        auditPass () {
            var id = this.aid;
            var data = {status:1}
            var url = 'admin/course/answer/audit/';
            this.apiPut(url, id, data).then((res) => {
                if (res.code != 200) {
                    this.handleError(res);
                } else {
                    this.$Message.success('审核完成');
                    this.$emit('closeAudit');
                }
            })
        },
        auditFailed() {
            var id = this.aid;
            var data = {status:2}
            var url = 'admin/course/answer/audit/';
            this.apiPut(url, id, data).then((res) => {
                if (res.code != 200) {
                    this.handleError(res);
                } else {
                    this.$Message.success('审核完成');
                    this.$emit('closeAudit');
                }
            })
        }
    },
    watch: {
        auditid: function(newid) {
            this.aid = newid;
        }
    },
    mixins: [http],
    props: ['auditid']
}
</script>